package com.yangfan.thread.thread_wangwenjun01;

/**
 * @description: Runnable 接口
 * @author: yangfan
 * @date: Created in 2020/1/21 0021 19:11
 * @modified By:
 */

public class ThreadFoundRunnable {

    /**
     * 继承 Thread 方式 实现一个  银行  4个窗口 叫号功能
     */
    public static void main(String[] args) {

        ThreadRunnable r = new ThreadRunnable();//任务
        //三个线程一起执行一个任务
        new Thread(r,"A").start();
        new Thread(r,"B").start();
        new Thread(r,"C").start();
    }

    /**
     * Runnable 可以看成是一个可以执行的任务。
     */
    static class ThreadRunnable implements Runnable{

        private static final int MAX = 50;
        private int index = 1;

        public void run() {
            while (index <= ThreadRunnable.MAX){
                System.out.println(Thread.currentThread().getName() + "当前叫号："+ (++index));
            }
        }
    }
}
